package com.tkk.monitoring.analyze.db;

import com.tkk.monitoring.analyze.AnalyzeTarget;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;

/**
 * author: Tkk
 * date: 2015/7/8
 */
public class History {
    private int id;

    private String host;
    private String port;
    private String path;
    private String get;
    private String post;

    public String getGet() {
        return get;
    }

    public void setGet(String get) {
        this.get = get;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public boolean equals(AnalyzeTarget target) {
        if (StringUtils.isNotBlank(get)) {
            if (target.getGetParam() != null) {
                return target.getGetParam().keySet().containsAll(Arrays.asList(get.split(",")));
            } else {
                return false;
            }
        }

        if (StringUtils.isNotBlank(post)) {
            if (target.getPostParam() != null) {
                return target.getPostParam().keySet().containsAll(Arrays.asList(post.split(",")));
            } else {
                return false;
            }
        }

        return false;
    }
}
